package com.black.utils.file.compress.jar.visitor;

import com.black.utils.file.compress.jar.entity.AnnotationInfo;
import com.black.utils.file.compress.jar.entity.MethodInfo;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

/**
 * @author ylx
 */
public class JarMethodVisitor extends MethodVisitor implements Opcodes {
    private final MethodInfo methodInfo;

    public JarMethodVisitor(MethodInfo methodInfo) {
        super(ASM7);
        this.methodInfo = methodInfo;
    }

    @Override
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
        AnnotationInfo annotationInfo = new AnnotationInfo(desc);
        methodInfo.addAnnotation(desc, annotationInfo);
        return new JarAnnotationVisitor(annotationInfo);
    }
}
